package com.example.myyiyanmengjava.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.example.mvplibrary.adapter.BaseAdapter;
import com.example.mvplibrary.adapter.BaseViewHolder;
import com.example.myyiyanmengjava.R;

import java.util.List;

public class TextViewAdapter extends BaseAdapter<String> {
    public onItemListener itemListener;

    public void setListener(onItemListener listener) {
        this.itemListener = listener;
    }

    public TextViewAdapter(List<String> datas, Context context, int layoutId) {
        super(datas, context, layoutId);
    }

    @Override
    protected void bindData(BaseViewHolder holder, String listBean, int position) {
        TextView text1 = holder.getView(R.id.tv_text);

        text1.setText(listBean);
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                itemListener.onClick(position);
            }
        });
    }

    public interface onItemListener {
        void onClick(int n);
    }
}
